package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import com.trkj.pojos.LmbPurchaseDetail;

public interface LmbPurchaseDetailDAO extends CrudRepository<LmbPurchaseDetail,String>{
	 //显示采购详情
  	@Query("select p from LmbPurchaseDetail p where p.pdCpId=?1 order by p.pdId desc")
  	public List<LmbPurchaseDetail> findPurchaseDetail(String id);
  	
  	@Query("select c from LmbPurchaseDetail c ,LmbMaterialAcceptance m WHERE m.matResult = ?1 and c.pdCpId = m.matCpId")
    public List<LmbPurchaseDetail> findResult(String result);

  	@Query("select s from LmbPurchaseDetail s WHERE s.pdCpId=?1 ")
    public List<LmbPurchaseDetail> findDetail(String pdCpId);
  	
  	 @Query("select max(c.pdId) from LmbPurchaseDetail c where c.pdId like ?1%")
     public String findMaxID(String a);
  	 
  	//根据采购单号查找采购详情
  	@Query("select c from LmbPurchaseDetail c where c.pdCpId=?1 order by c.pdId desc")
  	public List<LmbPurchaseDetail> findDetailByPdId(Pageable pageable,String pdId);
  	
  	@Query("select count(*) from LmbPurchaseDetail c where c.pdCpId=?1")
  	public long countDetailByPdId(String pdId);
}
